
from x_com import xport_core
from x_com import source_api
import x_com_lib
from x_com.import_api import electricity_data_source_service_0_0_1

logger = xport_core.getLogger()

class ElectricityDataSubscriberService:
    
  async def on_init(self):
    logger.info("on_init...")

  async def on_finalize(self):
    logger.info("on_finalize...")

  # SubscribeData
  async def subscribe_data(self, ctx: xport_core.Context):
    subscibe_info = x_com_lib.PySubscribeTopicInfo()

    subscibe_info.tag = [] 

    subscibe_info.topic = "Recharge"
    logger.info(f"节点 订阅 Recharge 事件...")
    x_com_lib.stream.dxc_subscribe_topic(subscibe_info)

    subscibe_info.topic = "Monitoring"
    logger.info(f"节点 订阅 Monitoring 事件...")
    x_com_lib.stream.dxc_subscribe_topic(subscibe_info)




    await electricity_data_source_service_0_0_1.subscribe_data()

